package com.atom.test.view

import android.graphics.BitmapFactory
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.atom.module.view.seekbar.WaveformSeekBar
import com.atom.module.view.banner.Banner
import com.atom.module.view.banner.adapter.BannerImageAdapter
import com.atom.module.view.banner.holder.BannerImageHolder

class ViewBannerActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_banner)
        val list = resources.assets.list("banner") ?: return
        list.forEach {
            Log.e("ViewBannerActivity", it)
        }
        val adapter = object : BannerImageAdapter<String>(list.asList()) {
            override fun onBindView(
                holder: BannerImageHolder?,
                data: String?,
                position: Int,
                size: Int
            ) {

                holder?.imageView?.setImageBitmap(
                    BitmapFactory.decodeStream(
                        resources.assets.open(
                           "banner/${data}"
                        )
                    )
                )
            }
        }
        val findViewById =
            findViewById<Banner<String, BannerImageAdapter<String>>>(R.id.bannerLayout)
        findViewById.setAdapter(adapter)
    }
}